df=read_xlsx("Data/sgRNA/Figure5/N100M_sequence_result/N100M_plot.xlsx") %>% 
  janitor::clean_names()

df <- df %>%
  mutate(point_size = ifelse(ladder_type == "Intact", 3.5, 2.5))  

ggplot(df, aes(x = monoisotopic_mass/1000, y = apex_rt, 
               color = log10(sum_intensity), 
               shape = ladder_type, 
               group = ladder_type)) +
  geom_point(aes(size = point_size)) +  # Map size to point_size inside aes()
  geom_line(color = "gray34", alpha = 0.5) +  # Add lines connecting points within the same ladder_type
  scale_x_continuous(name = "Monoisotopic Mass (kDa)", breaks = seq(0, max(df$monoisotopic_mass, na.rm = TRUE), by = 2)) +
  scale_y_continuous(name = "Retention Time (min)", limits = c(0,19), breaks = seq(0, 19, by = 2)) +
  labs(color = "Log10(Intensity)", shape = "Ladder Type", size = "Ladder Type") +  # Add size to legend
  theme_classic() +
  theme(
    axis.title.x = element_text(size = 12),
    axis.title.y = element_text(size = 12),
    axis.text.x = element_text(size = 10),
    axis.text.y = element_text(size = 10),
    legend.title = element_text(size = 10),
    legend.text = element_text(size = 10)
  ) +
  scale_color_gradientn(colors = turbo(256)) +  # Use turbo color scale for the color aesthetic
  scale_size_identity()  # Use the actual values in point_size for sizing
## Warning: Removed 4 rows containing missing values or values outside the scale range
## (`geom_point()`).
## Warning: Removed 4 rows containing missing values or values outside the scale range
## (`geom_line()`).

df=read_xlsx("Data/sgRNA/Figure5/N100N_sequence_result/N100N_plot.xlsx") %>% 
  janitor::clean_names()

df <- df %>%
  mutate(point_size = ifelse(ladder_type == "Intact", 3.5, 2.5))

ggplot(df, aes(x = monoisotopic_mass/1000, y = apex_rt, 
               color = log10(sum_intensity), 
               shape = ladder_type, 
               group = ladder_type)) +
  geom_point(aes(size = point_size)) +  # Map size to point_size inside aes()
  geom_line(color = "gray34", alpha = 0.5) +  # Add lines connecting points within the same ladder_type
  scale_x_continuous(name = "Monoisotopic Mass (kDa)", breaks = seq(0, max(df$monoisotopic_mass, na.rm = TRUE), by = 2)) +
  scale_y_continuous(name = "Retention Time (min)", limits = c(0, 19), breaks = seq(0, 19, by = 2)) +
  labs(color = "Log10(Intensity)", shape = "Ladder Type", size = "Ladder Type") +  # Add size to legend
  theme_classic() +
  theme(
    axis.title.x = element_text(size = 12),
    axis.title.y = element_text(size = 12),
    axis.text.x = element_text(size = 10),
    axis.text.y = element_text(size = 10),
    legend.title = element_text(size = 10),
    legend.text = element_text(size = 10)
  ) +
  scale_color_gradientn(colors = turbo(256)) +  # Use turbo color scale for the color aesthetic
  scale_size_identity()  # Use the actual values in point_size for sizing
## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).
## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_line()`).

plot_mixture("Data/sgRNA/Figure5/N100_mixture_result/100NM_19/100NM19_plot.xlsx")
## New names:
## • `` -> `...8`
## • `` -> `...9`
## • `` -> `...10`
## • `` -> `...11`
## Warning in RColorBrewer::brewer.pal(N, "Set2"): minimal value for n is 3, returning requested palette with 3 different levels
## Warning in RColorBrewer::brewer.pal(N, "Set2"): minimal value for n is 3, returning requested palette with 3 different levels
plot_mixture("Data/sgRNA/Figure5/N100_mixture_result/100NM_55/100NM55_plot.xlsx")
## Warning in RColorBrewer::brewer.pal(N, "Set2"): minimal value for n is 3, returning requested palette with 3 different levels
## Warning in RColorBrewer::brewer.pal(N, "Set2"): minimal value for n is 3, returning requested palette with 3 different levels
plot_mixture("Data/sgRNA/Figure5/N100_mixture_result/100NM_91/100NM91_plot.xlsx")
## New names:
## • `` -> `...8`
## • `` -> `...9`
## Warning in RColorBrewer::brewer.pal(N, "Set2"): minimal value for n is 3, returning requested palette with 3 different levels
## Warning in RColorBrewer::brewer.pal(N, "Set2"): minimal value for n is 3, returning requested palette with 3 different levels
df = read_xlsx("Data/sgRNA/Figure5/N100_mixture_result/mixture_coverage.xlsx") 
## New names:
## • `` -> `...4`
## • `` -> `...5`
## • `` -> `...6`
## • `` -> `...7`
## • `` -> `...8`
## • `` -> `...9`
df = head(df, 10)

ggplot(df, aes(x = sgRNA1_percentage, y = coverage, fill = sgRNA_type)) +
  geom_bar(stat = "identity", position = position_dodge(width = 2.5), width = 2) +
  labs(
    x = "Percentage sgRNA1 in mixture(%)",
    y = "Percent Sequence Coverage(%)",
    fill = "sgRNA Type"
  ) +
  scale_x_continuous(breaks = c(10, 30, 50, 70, 90)) +
  theme_minimal() +
  scale_fill_brewer(palette = "Set1")